<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>挖坑日志原型--design by luob</title>
            <!--<script id="jquery_183" type="text/javascript" class="library" src="http://sandbox.runjs.cn/js/sandbox/jquery/jquery-1.8.3.min.js"></script>-->
            
            <script src="jQuery-contextMenu/jquery-1.8.2.min.js" type="text/javascript"></script>
            <script src="jQuery-contextMenu/src/jquery.ui.position.js" type="text/javascript"></script>
            <script src="jQuery-contextMenu/src/jquery.contextMenu.js" type="text/javascript"></script>
            <script src="jQuery-contextMenu/prettify/prettify.js" type="text/javascript"></script>
            <script src="jQuery-contextMenu/screen.js" type="text/javascript"></script>
            
            <link href="jQuery-contextMenu/src/jquery.contextMenu.css" rel="stylesheet" type="text/css" />
            <link href="jQuery-contextMenu/screen.css" rel="stylesheet" type="text/css" />
            <link href="jQuery-contextMenu/prettify/prettify.sunburst.css" rel="stylesheet" type="text/css" />
            
            <!--<link rel="stylesheet" type="text/css" href="my.css">-->
            <!--<script type="text/javascript" src="my.js"></script>
            <script type="text/javascript" src="bizButtonManager.js"></script>
            <script type="text/javascript" src="systemBiz.js"></script>-->
            <script src="Math.uuid.js" type="text/javascript"></script>
			<script type="text/javascript">
			var kengDataMap = {};
			var eventDataMap = {};
			var idGenerater = {
			generateIdSeq:function(range){
				return Math.floor(Math.random()*(range==undefined?10000:range));
			}
			};
			var kengPojo = {module:{
				p0:"ID",
				p1:"坑名"},
				createOne:function(){
				var d = {};
					for(a in kengPojo.module) {
						d[a] = "";
					}
					d.p0 = "K"+idGenerater.generateIdSeq();
					return d;
				}};
			var eventPojo = {module:{
				p0:"ID",
				p1:"坑名",
				p11:"系统事件类型",
				p2:"创建时间",
				p3:"创建地点",
				p4:"事件时间",
				p5:"事件地点",
				p6:"主语",
				p7:"事情描述",
				p8:"参与人",
				p9:"创建人"},
				createOne:function(){
					var d = {};
					for(a in eventPojo.module) {
						d[a] = "";
					}
					d.p0 = "E"+idGenerater.generateIdSeq();
					return d;
				}};
			var bizMethod = {
				generateKeng:function(){
					var d = kengPojo.createOne();
					htmlControler.loadGenerateKengToPage(d);
				},
				submitKeng:function(){
					var d = htmlControler.loadGenerateKengFromPage();
					kengDataMap[d.p0]=d;
					htmlControler.flushKengDataTable();
				},
				generateEvent:function(){
					var d = evnetPojo.createOne();
					htmlControler.loadGenerateEvent(d);
				},
				submitEvent:function(){
				
				},
			};
			var htmlControler = {
				loadGenerateKengToPage:function(d){
					var i = 0;
					for(a in d) {
						$($("#kengDataGenerateDiv input")[i]).val(d[a]);
						i++;
					}
				},
				loadGenerateKengFromPage:function(){
					var d = kengPojo.createOne();
					var i = 0;
					for(a in d) {
						d[a] = $($("#kengDataGenerateDiv input")[i]).val();
						i++;
					}
					if(null==d||d.p0==undefined||d.p0=="")return null;
					$("#kengDataGenerateDiv input").val("");
					return d;
				},
				flushKengDataTable:function() {
					$("#kengDataTable").find("tr").each(function(){
												if(this.firstChild.nodeName == "TD") {
												this.parentNode.removeChild(this);
												}
												});
					for(d in kengDataMap) {
						var data = kengDataMap[d];
						var tds = [];
						for(a in data) {
							tds.push(data[a]);
						}
						var tr = this.newTR(tds);
						var id=Math.uuid();
						tr.attr("id",id);
						tr.attr("bizId",data.p0);
						$("#kengDataTable").append(tr);
						//this.bindErpTrContextMenu("#"+id);
					}
				},
				loadGenerateEventToPage:function(d){
					
				},
				newTR : function(tds) {
					var tr = $("<tr></tr>");
					for(var i=0; i<tds.length; i++) {
						var td =$("<td></td>");
						td.text(tds[i]);
						tr.append(td);
					}
					return tr;
				}
			};
			</script>
            </head>
    <body>
		<fieldset id="kengDataGenerateDiv"><legend>坑生成工具</legend>ID<input />坑名<input /><button onclick="bizMethod.generateKeng()">生成</button><button onclick="bizMethod.submitKeng()">提交</button></fieldset>
        <table id="kengDataTable" border=1><caption>挖过的坑</caption>
		<tr><th>ID</th><th>坑名</th></tr>
		</table>
		<fieldset id="kengDataGenerateDiv"><legend>事件生成工具</legend>ID<input />坑名<input />创建时间<input />创建地点<input />事件时间<input />
		事件地点<input />主语<input />事情描述<input />参与人<input /><button>生成</button><button>提交</button></fieldset>
        <table border=1><caption>事件日志</caption>
		<tr><th>ID</th><th>坑名</th><th>创建时间</th><th>创建地点</th><th>事件时间</th><th>事件地点</th><th>主语</th><th>事情描述</th><th>参与人</th></tr>
		</table>
    </body>
</html>